FROM ubuntu:16.04
MAINTAINER Dean dmh@xiaogu-tech.com
CMD ["bash"]

# install tools
RUN apt-get update && apt-get install -y sudo\
		   && apt-get install -y wget\
	           && apt-get install -y python3.5\
		   && apt-get install -y vim\
		   && apt-get install -y curl\
                   && apt-get install -y unzip\
		   && apt-get install -y python3-pip

# install java
RUN echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | debconf-set-selections
RUN echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee /etc/apt/sources.list.d/webupd8team-java.list  
RUN echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list  
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886  
RUN apt-get update && apt-get install -y oracle-java8-installer  

# add user
RUN useradd -m cogik -s /bin/bash
RUN echo root:123456|chpasswd
RUN echo cogik:123456|chpasswd
RUN adduser cogik sudo
RUN echo "cogik ALL= (ALL) NOPASSWD:ALL">>/etc/sudoers
USER cogik

# install elasticsearch
WORKDIR /home/cogik
RUN wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.5.0.zip
RUN wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v5.5.0/elasticsearch-analysis-ik-5.5.0.zip
RUN unzip -d /home/cogik /home/cogik/elasticsearch-5.5.0.zip 
RUN unzip -d /home/cogik/elasticsearch-5.5.0/plugins/ik /home/cogik/elasticsearch-analysis-ik-5.5.0.zip
RUN rm elasticsearch-5.5.0.zip && rm elasticsearch-analysis-ik-5.5.0.zip
RUN /home/cogik/elasticsearch-5.5.0/bin/elasticsearch-plugin install x-pack

# install django
RUN sudo pip3 install django==1.11.1
RUN sudo pip3 install django-extensions
RUN sudo pip3 install django-markdownx
RUN sudo pip3 install django-crispy-forms
RUN sudo pip3 install django-datetime-widget
RUN sudo pip3 install djangorestframework
RUN rm -rf /home/cogik/.cache/*

VOLUME ["/usr/docker_shares"]

EXPOSE 9200
EXPOSE 9300





